<div class="problemindexholder" problemindex="A">
 <div class="ttypography">
  <div class="problem-statement">
   <div class="header">
    <div class="title">
     A. QAQ
    </div>
    <div class="time-limit">
     <div class="property-title">
      time limit per test
     </div>
     1 second
    </div>
    <div class="memory-limit">
     <div class="property-title">
      memory limit per test
     </div>
     256 megabytes
    </div>
    <div class="input-file">
     <div class="property-title">
      input
     </div>
     standard input
    </div>
    <div class="output-file">
     <div class="property-title">
      output
     </div>
     standard output
    </div>
   </div>
   <div>
    <p>
     "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.
    </p>
    <p>
     Now Diamond has given Bort a string consisting of only uppercase English letters of length
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     . There is a great number of "QAQ" in the string (Diamond is so cute!).
    </p>
    <center>
     <img class="tex-graphics" height="259px" src="/predownloaded/9d/8e/9d8e4fde91e4d705d4e31f89d1aa273864c6fcb1.png" style="max-width: 100.0%;max-height: 100.0%;" width="340px"/>
     <span class="tex-font-size-tiny">
      illustration by 猫屋 https://twitter.com/nekoyaliu
     </span>
    </center>
    <p>
     Bort wants to know how many subsequences "
     <span class="tex-font-style-tt">
      QAQ
     </span>
     " are in the string Diamond has given. Note that the letters "
     <span class="tex-font-style-tt">
      QAQ
     </span>
     " don't have to be consecutive, but the order of letters should be exact.
    </p>
   </div>
   <div class="input-specification">
    <div class="section-title">
     Input
    </div>
    <p>
     The only line contains a string of length
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       n
      </i>
      ≤ 100
     </span>
     ). It's guaranteed that the string only contains uppercase English letters.
    </p>
   </div>
   <div class="output-specification">
    <div class="section-title">
     Output
    </div>
    <p>
     Print a single integer — the number of subsequences "
     <span class="tex-font-style-tt">
      QAQ
     </span>
     " in the string.
    </p>
   </div>
   <div class="sample-tests">
    <div class="section-title">
     Examples
    </div>
    <div class="sample-test">
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>QAQAQYSYIOIWIN<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>4<br/></pre>
     </div>
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>QAQQQZZYNOIWIN<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>3<br/></pre>
     </div>
    </div>
   </div>
   <div class="note">
    <div class="section-title">
     Note
    </div>
    <p>
     In the first example there are
     <span class="tex-span">
      4
     </span>
     subsequences "
     <span class="tex-font-style-tt">
      QAQ
     </span>
     ": "
     <span class="tex-font-style-tt">
      <span class="tex-font-style-bf">
       QAQ
      </span>
      AQYSYIOIWIN
     </span>
     ", "
     <span class="tex-font-style-tt">
      <span class="tex-font-style-bf">
       QA
      </span>
      QA
      <span class="tex-font-style-bf">
       Q
      </span>
      YSYIOIWIN
     </span>
     ", "
     <span class="tex-font-style-tt">
      <span class="tex-font-style-bf">
       Q
      </span>
      AQ
      <span class="tex-font-style-bf">
       AQ
      </span>
      YSYIOIWIN
     </span>
     ", "
     <span class="tex-font-style-tt">
      QA
      <span class="tex-font-style-bf">
       QAQ
      </span>
      YSYIOIWIN
     </span>
     ".
    </p>
   </div>
  </div>
  <p>
  </p>
 </div>
</div>
